<?php
$save=save_img();
$res=array(
    'code'=>0,
    'msg'=>"",
     );

if($save){
    $res['code']=1;
    $res['msg']=$save[0];
}

echo json_encode($res);die;

function save_img(){
    $save_file=array();
    foreach ($_FILES as $value) {
      if ((($value["type"] == "image/bmp")
      || ($value["type"] == "image/jpeg")
      || ($value["type"] == "image/gif")
      || ($value["type"] == "image/png")
      || ($value["type"] == "image/pjpeg"))
      && ($value["size"] > 0 || $value["size"] < 5120000  ))
        {
          if ($value["error"] > 0){}
          else{
            $filename=random_str(10);
            move_uploaded_file($value["tmp_name"],"../upload/".$filename.".jpg");
            $save_file[count($save_file)]="/"."upload/".$filename.".jpg";
          } 
        }
    }

      return $save_file;
  }

  function random_str($unm){
    $string=explode(",","0,1,2,3,4,5,6,7,8,9,A,B,C,D,E,F,G,H,I,J,K,L,M,N,O,P,Q,R,S,T,U,V,W,X,Y,Z,a,b,c,d,e,f,g,h,i,j,k,l,m,n,o,p,q,r,s,t,u,v,w,x,y,z");
    $get="";
    for ($i=0; $i <$unm ; $i++) { 
      $get.=$string[mt_rand(0,count($string)-1)];
    }
    return $get;
  }